package games;

import java.util.List;

/**
 * Created by samilc on 12/26/14.
 */
public class TradeCommand extends Command {
    Player p1;
    Player p2;
    List<Property>pr1;
    List<Property> pr2;
    int mp1;
    int mp2;
    TradeCommand(Player p1, Player p2, List<Property> pr1, List<Property> pr2,int mp1, int mp2){
        this.p1 = p1;
        this.p2 = p2;
        this.pr1 = pr1;
        this.pr2 = pr2;
        this.mp1 = mp1;
        this.mp2 = mp2;
    }

    public void excecute(){
        p1.loseMoney(mp2);
        p1.earnMoney(mp1);
        p2.loseMoney(mp1);
        p2.earnMoney(mp2);

        for (int i = 0; i <pr1.size() ; i++) {
            p2.myProperties.remove(pr1.get(i));
            p1.myProperties.add(pr1.get(i));
        }

        for (int i = 0; i <pr2.size() ; i++) {
            p1.myProperties.remove(pr2.get(i));
            p2.myProperties.add(pr2.get(i));
        }
    }
}
